package chapter13.eg2;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.junit.Test;

public class ByteBufDemo {
  @Test
  public void testEnsureCapacity() {
    ByteBuf buf = Unpooled.buffer(3 * 1024 * 1024);
    byte[] initBytes = new byte[3 * 1024 * 1024];
    buf.writeBytes(initBytes);
    System.out.println("capacity: " + buf.capacity() + ", readIndex: " + buf.readerIndex() + ", writerIndex: " + buf.writerIndex());

    byte[] expandBytes = new byte[2 * 1024 * 1024];
    buf.writeBytes(expandBytes);
    System.out.println("capacity: " + buf.capacity() + ", readIndex: " + buf.readerIndex() + ", writerIndex: " + buf.writerIndex());

  }

}
